Skip to content

Accept repeated prototypes for extern inline functions, without dropping the prototyped function#227

Open
stephenrkell wants to merge 2 commits into
goblint:developfrom
stephenrkell:goblint-extinlinefix
Open

Accept repeated prototypes for extern inline functions, without dropping the prototyped function#227
stephenrkell wants to merge 2 commits into
goblint:developfrom
stephenrkell:goblint-extinlinefix

Conversation

@stephenrkell
Copy link
Copy Markdown

Given code like this:

extern void f(void);
extern inline __attribute__((always_inline)) void g()
{
        f();
}

extern inline __attribute__((always_inline)) void g();
void v(void)
{
        g();
}

... CIL will replace its definition of g() when it sees the second prototype, making it appear wrongly to be a prototype-only function. The C that is printed will lack the definition of g(). Then compilation will fail with an error like the following.

./extinline4.cil.c: In function ‘v’:
./extinline4.cil.c:5:59: error: inlining failed in call to ‘always_inline’ ‘g’: function body not available
    5 | __inline extern void ( __attribute__((__always_inline__)) g)(void) ;
      |                                                           ^
./extinline4.cil.c:13:3: note: called from here
   13 |   g();
      |   ^~~

This PR fixes this, by splitting out the cases of newly seen function definitions versus declarations.

@stephenrkell
Copy link
Copy Markdown
Author

stephenrkell commented Apr 29, 2026

By the way, I have lots of fixes like this that have been sitting in my personal CIL fork for years. I'd like to contribute them. By default I'll open PRs on a rolling basis (some also by my current and past collaborators @mbyzhang and @probablytom) but let us know if there's a better way.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant